<template>
  <!-- 已录入 -->
  <div class="box clearfix">
    <section class="section_wrap">
      <FunctionalAreas></FunctionalAreas>
      <div class="title_sub prduct_bod_r">产品说明：</div>
      <ProductDescriptionToo></ProductDescriptionToo>
    </section>
    <section class="section_wrap">
      <div class="title_sub infro_bod_l">信息查看：</div>
      <div class="state">状态：已录入</div>
      <InformationsViewer
        v-if="template === 'template_01'"
        :orderNumber="orderNumber"
        :showButton="showButton"
      ></InformationsViewer>
      <InformationsViewer02
        v-if="template === 'template_02'"
        :orderNumber="orderNumber"
        :showButton="showButton"
      ></InformationsViewer02>
    </section>
    <section class="section_wrap"  v-if="showFinancialInfo">
      <div class="title_sub infro_bod_l">财务信息:</div>
      <financialInfo :showBtn="showBtn" :orderNumber="orderNumber"></financialInfo>
    </section>
    <section class="section_wrap">
      <div class="title_sub infro_bod_l">风控大数据查询:</div>
      <viewInfo :userData="userData"></viewInfo>
    </section>
    <section class="section_wrap" v-if="showChannelSign">
      <div class="title_sub upload_bod_l">签约：</div>
      <ChannelSign :orderNumber="orderNumber"></ChannelSign>
    </section>
    <section class="section_wrap">
      <div class="title_sub upload_bod_l">附件管理：</div>
      <!-- 上传组件 -->
      <Upload ref="Uploade" :isNew="isNew"></Upload>
    </section>
    <section class="section_wrap">
      <Attachment></Attachment>
      <div>
        <el-button
          type="primary"
          class="primaryButton"
          @click="primaryButton"
          v-if="showOrderCommit"
          >提交审批</el-button
        >
      </div>
      <div class="title_sub infro_bod_l">操作记录：</div>
      <OperationRecords :orderNumber="orderNumber"></OperationRecords>
    </section>
  </div>
</template>

<script>
import {
  putOrderCommit,
  getProductUrl,
  getOrderOne,
} from "../../../src/assets/js/api";
import FunctionalAreas from "../../components/meitList/FunctionalAreas";
import ProductDescriptionToo from "../../components/meitList/ProductDescriptionToo";
import InformationsViewer from "../../components/meitList/InformationsViewer";
import InformationsViewer02 from "../../components/meitList/InformationsViewer02";
import Attachment from "../../components/meitList/Attachment";
import Upload from "../../components/meitList/Upload";
import ChannelSign from "../../components/signUp/ChannelSign";

import OperationRecords from "../../components/meitList/OperationRecords";
import viewInfo from "../../components/business/viweInfo.vue";

import { checkPermiss } from "../../assets/js/utlis";
import financialInfo from "../../components/business/financialInfo";

export default {
  name: "HasBeenRecorded",
  components: {
    FunctionalAreas,
    ProductDescriptionToo,
    InformationsViewer,
    InformationsViewer02,
    Attachment,
    Upload,
    ChannelSign,
    OperationRecords,
    viewInfo,
    financialInfo,
  },
  data() {
    return {
      //TODO
      showChannelSign: false,
      showButton: true,
      isNew: false,
      orderNumber: "",
      markUpdate: "",
      golbalPermissions: [],
      ProductUrl: "",
      template: "",
      prductId: "",
      userData: {},
    };
  },
  created() {
    this.golbalPermissions = localStorage.getItem("permissions").split(",");
    this.prductId = parseInt(sessionStorage.getItem("prductId"));
    this.getOrderNum();
    this.getProductUrl();
    this.getOrderOne(this.prductId);
  },
  computed: {
    //财务信息按钮显示
    showBtn: function() {
      return checkPermiss("business:updateFinancial:ryd", this.golbalPermissions);

    },
    //财务信息
    showFinancialInfo: function() {
      return checkPermiss("business:upForm:financial:ryd", this.golbalPermissions);
    },
    //提交审批按钮
    showOrderCommit: function () {
      return checkPermiss("business:order:commit", this.golbalPermissions);
    },
  },
  methods: {
    // getUserData(data) {
    //   this.userData = data;
    //   console.log(this.userData);
    // },
    getOrderOne(id) {
      getOrderOne(id).then((res) => {
        this.template = res.data.pcCode;
      });
    },
    //根据orderNumber判断跳转的产品路径
    getProductUrl() {
      getProductUrl({ orderNumber: this.orderNumber }).then((res) => {
        this.ProductUrl = res.data.productUrl;
      });
    },
    //判断获取orderNumber
    getOrderNum() {
      let orderNumber = this.$route.query.orderNumber;
      if (orderNumber) {
        this.orderNumber = orderNumber;
      } else {
        this.orderNumber = sessionStorage.getItem("orderNumber");
      }
    },
    //提交审批按钮
    primaryButton() {
      //验证审批的身份证图片
       let accList = this.$refs.Uploade.accList;
      var idStatus = false;
      if (
        accList.type1face.data.length > 0 &&
        accList.type1back.data.length > 0
      ) {
        idStatus = true;
      }
      if (!idStatus) {
        this.$message({
          message: "请上传身份证件照",
          type: "error",
        });
      } else {
        putOrderCommit(this.orderNumber).then((res) => {
          this.$message({
            message: res.message,
            type: "success",
          });
          this.$router.replace({ path: this.ProductUrl });
        });
      }
    },
  },
};
</script>

<style scoped type="less">
.text {
  font-size: 20px;
  font-weight: bold;
  text-align: left;
  margin-top: 20px;
  text-indent: 2em;
}
.state {
  font-size: 22px;
  font-weight: bold;
  float: right;
  margin-top: -20px;
  margin-right: 3%;
}

.uploadStyle {
  width: 97%;
  position: relative;
  margin-top: 20px;
}
.primaryButton {
  width: 180px;
  height: 45px;
  margin-top: 20px;
}
</style>
